﻿	CREATE TABLE public.account
	(
	    /***************************************************************************************************
	    **  Table:	    public.account
	    **  Author:		Zhixian Ong
	    **
	    **  Description:
	    **    
	    **    Represents a registered account.
	    **
	    **  Fields (2):
	    **
	    **      id                  - candidate key
	    **      username            - username
	    **      password_hash       - password hash
        **      password_salt       - password salt
	    **      password_timestamp  - date that password was set
	    **      login_timestamp     - date that password was set
	    **
	    **  Constaints (2):
	    **
	    **      account_pk  - 
	    **      account_uc  - 
	    **      
	    **
	    **  Modification History:
	    **
	    **      20140102  Zhixian Ong     - Initial prototype
	    ** 
	    **  Status:
	    **      Dev
	    ** 
	    ***************************************************************************************************/
        
	    -- [Fields]
	    id                  integer                 NOT NULL DEFAULT nextval('account_id_seq'),
	    username            character varying(36)   NOT NULL,
	    password_hash       character varying(128)  NOT NULL, 
        password_salt       character varying(128)  NOT NULL,
        password_timestamp  timestamp               NOT NULL DEFAULT current_date - interval '90 days',
        login_timestamp     timestamp               NULL,
        
	    -- [Constraints]
	    CONSTRAINT account_pk   PRIMARY KEY ("id"),
	    CONSTRAINT account_uc   UNIQUE ("username")
	);